Imports System.Configuration

Public Class CCommon
    Dim _strBillID As String
    Dim _intSaleID As Integer
    Enum enmCommonSearchFor
        PRODUCT = 1
        PROMOTER = 2
        COLOR = 3
        PARTY = 4
        SITE = 5
        GODOWN = 6
    End Enum

    Public Shared Function GetUserID() As String
        'Returns LoginID of the user currently login the system
        Try
            'Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader
            Return CStr(ConfigurationManager.AppSettings("UserID"))
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Public Enum SearchList
        PROMOTER_CODE = 1
        PROMOTER_NAME = 2
    End Enum
    Public Shared Function GetFinYrID() As Integer
        'Returns LoginID of the user currently login the system
        Try
            'Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader
            Return CStr(ConfigurationManager.AppSettings("FinYrId"))
        Catch ex As Exception
            Return 0
        End Try
    End Function


    Public Shared Function RemoveAnd(ByVal strText As String) As String
        'Returns string removing '&' from strText
        Dim subStrings() As String
        Dim ReturnStr As String = ""
        Dim i As Integer

        subStrings = strText.Split("&")

        For i = 0 To subStrings.GetUpperBound(0)
            ReturnStr = ReturnStr & subStrings(i)
        Next

        Return ReturnStr
    End Function

    Public Shared Sub CopyArray(ByRef SourceArray As System.Array, ByRef DestinationArray As System.Array)
        Dim i As New Integer
        For i = 0 To SourceArray.Length - 1
            If Not IsNothing(SourceArray(i)) Then
                DestinationArray(i) = SourceArray(i).copy()
            Else
                DestinationArray(i) = Nothing
            End If
        Next
    End Sub

    Public Shared Function GetSystemResolution() As String
        Dim intX As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
        Dim intY As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
        Return intX & " X " & intY
    End Function
    Public Property BillID() As String
        Get
            Return _strBillID
        End Get
        Set(ByVal value As String)
            _strBillID = value
        End Set
    End Property
    Public Property SaleID() As String
        Get
            Return _intSaleID
        End Get
        Set(ByVal value As String)
            _intSaleID = value
        End Set
    End Property


    '-----------------------------------------------------------------------------------------------
    'Public Shared Function GetDbDate() As Integer
    '    'Returns Todays date in Database Format 'YYYYMMDD

    '    Dim myDate As String
    '    Try
    '        myDate = CStr(Now.Year) & CStr(Now.Month) & CStr(Now.Day)
    '        Return CInt(myDate)
    '    Catch ex As Exception

    '    End Try

    'End Function

    'Public Shared Function GetDbDate(ByVal tDate As Date) As Integer
    '    'Returns Passed tDate in Database Format 'YYYYMMDD
    '    Dim myDate As String

    '    Try

    '        myDate = Format(tDate, "yy") & Format(tDate, "MM") & Format(tDate, "dd")
    '        Return CInt(myDate)

    '    Catch ex As Exception

    '    End Try

    'End Function
    'Public Shared Function GetCompName() As String
    '    Return ""
    'End Function
    'Public Shared Function GetDbTime() As String
    '    'Returns Current time in Database Format 'HHMMSS

    '    Dim myDate As String

    '    Try
    '        myDate = Format(Now, "HH") & Format(Now, "mm") & Format(Now, "ss")
    '        Return myDate


    '    Catch ex As Exception
    '        Return ""
    '    End Try

    'End Function


    'Public Shared Function GetDbTime(ByVal tDate As Date) As String
    '    'Returns Passed tDate time in Database Format 'HHMMSS
    '    Dim myDate As String

    '    Try
    '        myDate = Format(CStr(tDate.Hour), "HH") & Format(CStr(tDate.Minute), "mm") & Format(CStr(tDate.Second), "ss")
    '        Return myDate
    '    Catch ex As Exception
    '        Return ""
    '    End Try
    'End Function


    'Public Shared Function GetDbToDate(ByVal dbDate As Integer) As Date
    '    'Returns Passed DbFormat Date To UserFormat
    '    Dim myDate As String = CStr(dbDate)

    '    Try
    '        Return CDate(Format(Mid(dbDate, 7, 2) & "/" & Mid(dbDate, 5, 2) & "/" & Mid(dbDate, 1, 4), "dd/MM/yyyy"))
    '    Catch ex As Exception

    '    End Try
    'End Function
    '-----------------------------------------------------------------------------------------------
End Class


